package com.atguigu.daijia.customer.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceHttpClientImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @description: 微信配置类
 * @name: WxConfigOperator
 * @author: wgp
 * @date: 2024/8/9 8:59
 */
@Component
public class WxConfigOperator {

    @Resource
    private WxConfigProperties wxConfigProperties;


    @Bean
    public WxMaService WxMaService(){
        WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
        wxMaConfig.setAppid(wxConfigProperties.getAppId());
        wxMaConfig.setSecret(wxConfigProperties.getSecret());
        WxMaService wxMaService = new WxMaServiceHttpClientImpl();
        wxMaService.setWxMaConfig(wxMaConfig);
        return wxMaService;
    }

}
